#pragma once

#include "winos.h"
#include "win_function_wrapper.h"

_SSL_BEGIN
_SSWINOSL_BEGIN

_SSBASEL_USE_NP

class SSWINOS_CLASS cs_lock
{
public:
	cs_lock();
	virtual ~cs_lock();

	bool try_enter();
	void enter();
	void leave();

protected:
	CRITICAL_SECTION cs_;
	win_function_wrapper wrapper_;
};

class SSWINOS_CLASS auto_cs_guard
{
public:
	auto_cs_guard(cs_lock &lock);
	auto_cs_guard(const auto_cs_guard &other);
	virtual ~auto_cs_guard();

protected:
	cs_lock &locker_;
};

#define CsLockGuard(lock) auto_cs_guard ____autolock(lock)

_SSWINOSL_END
_SSL_END
